<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>新增人工</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/static/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/css/frame.css">

    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
</head>
<body style="background-color: rgb(255, 255, 255);">           
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>新增人工</legend>
</fieldset>

<form class="layui-form layui-form-pane" action="" lay-filter="example" style="padding: 20px">
    <div class="layui-form-item">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-inline" style="width: 40%">
            <input type="text" name="name" lay-verify="name" autocomplete="off" placeholder="请输入姓名" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">联系方式</label>
        <div class="layui-input-inline" style="width: 40%">
            <input type="text" name="mobile" lay-verify="mobile" autocomplete="off" placeholder="请输入联系方式" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">身份证号</label>
        <div class="layui-input-inline" style="width: 40%">
            <input type="text" name="card_id" lay-verify="card_id" autocomplete="off" placeholder="请输入身份证号" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">开户银行</label>
        <div class="layui-input-inline" style="width: 40%">
            <input type="text" name="bank_name" lay-verify="bank_name" autocomplete="off" placeholder="请输入开户银行" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">银行卡号</label>
        <div class="layui-input-inline" style="width: 40%">
            <input type="text" name="bank_code" lay-verify="bank_code" autocomplete="off" placeholder="请输入银行卡号" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item" pane="" style="width: 47.5%">
        <label class="layui-form-label">工种</label>
        <div class="layui-input-block">
            {foreach $cate_list as $k => $v}
                <input type="checkbox" name="cate_id" value="{$v.id}" title="{$v.name}">
            {/foreach}
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit="" lay-filter="submit">立即提交</button>
            <a href="javascript:history.back(-1)" class="layui-btn layui-btn-primary">返回</a>
        </div>
    </div>
</form>
          
<script src="/static/layui/layui.js" charset="utf-8"></script>

<script>
    layui.use(['form', 'layedit', 'laydate'], function(){
        var form = layui.form;

        // 监听提交
        form.on('submit(submit)', function(data){
            let loading = layer.msg('正在新增，请稍后...', {icon: 16, shade: 0.3, time:0});
            let cate_id = '';

            $("input[name='cate_id']:checked").each(function(){
                cate_id += $(this).val() + ','
            });

            data.field.cate_id = cate_id;

            $.post('{:url("Worker/worker_bank_add_data")}', data.field, function(res){
                if(res.code == 0){
                    layer.close(loading);
                    if(res.code == 0){
                        layer.msg(res.msg, {icon: 1,time: 1500}, function(){
                            history.back(-1);
                        });
                    }else{
                        layer.msg(res.msg, {icon: 2});
                    }
                }else{
                    layer.msg(res.msg, {icon: 2});
                }
            })
            return false;
        });
    });
</script>
</body>
</html>